# coding=utf-8
import BaseXClient
from xml.dom.minidom import Document

__author__ = 'Robert'
doc = Document()
word_id = doc.createElement("word_id")
word = doc.createElement("word")
source = doc.createElement("source")
origins = doc.createElement("origins")
morphemes = doc.createElement("morphemes")
sentence_last_used = doc.createElement("sentence_last_used")

try:
    # create session
    session = BaseXClient.Session('localhost', 1984, 'admin', 'admin')

    # create empty database
    session.execute("create db database")
    print session.info()

    # add document
    session.add("doc.xml")
    print session.info()

    # run query on database
    print "\n" + session.execute("xquery collection('database')")

    # close session
    session.close()

except IOError as e:
    # print exception
    print e





